package cool.qingqing.hero.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cool.qingqing.hero.entity.Heros;
import cool.qingqing.hero.service.IHerosService;
import cool.qingqing.result.Result;
import cool.qingqing.result.ResultEnum;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

import org.hibernate.validator.internal.util.logging.Log_.logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author gaoshanqing
 * @since 2023-10-15
 */
@Slf4j
@RestController
public class HerosController {

    

    @Autowired
    private IHerosService herosService;


    @GetMapping("/heroes")
    public Result heroes() {
        log.info("所有英雄");
        return new Result<>().setCode(ResultEnum.GET).setData(herosService.list());
    }

    @GetMapping("/heroes/{id}")
    public Result heroes(@PathVariable("id") int id){
         Heros hero=herosService.getById(id);
         List list=List.of(hero);
        return new Result<>().setData(list).setCode(ResultEnum.GET);

    }



}
